home *** CD-ROM | disk | FTP | other *** search
/ QuickTime for the Web (2nd Edition) / QuickTime for the Web (2nd Edition).iso / pc / Demos / Mac / Matthew's Behaviors / Matthew'sMotionƒ / MouseTurnover < prev    next >
Encoding:
INI File  |  2001-09-10  |  2.9 KB  |  85 lines

  1. [Name]
  2. MouseTurnOver - From Matthew's Motion Suite.
  3. By Matthew Peterson, matthew@pinoko.berkeley.edu
  4.  
  5. [Description]
  6. 2-19-2000
  7. Drop this on a sprite to make it a two-sided Button.
  8. When the mouse moves over, it turn around to let you 
  9. see the other side. Can be usefull in making card games.
  10.  
  11. [Parameters]
  12.  
  13. Side 1 Image Index, MP_SpinSideOneImage,1
  14. Side 2 Image Index, MP_SpinSideTwoImage,2
  15.  
  16.  
  17. [Mouse Enter]
  18. spritevars turningover
  19. turningover = 1
  20.  
  21.  
  22. [Mouse Exit]
  23. SpriteVars turningover turnback 
  24. if(not turningover)
  25.     turnback = true
  26. endif
  27.  
  28. [Frame loaded]
  29. spritevars  turningover  turnfirstimage turnsecondimage originalspincenterx originalspincentery spincenterx spincentery spinanglestep originalheight
  30.  
  31. turningover = 0
  32. spriteofid($thisspriteid).executeevent(200082)
  33. originalheight = spriteofid($thisspriteid).boundsbottom - spriteofid($thisspriteid).boundstop
  34. originalspincenterx = spincenterx
  35. originalspincentery = spincentery
  36. spinanglestep = 180/9
  37. turnfirstimage = $MP_SpinSideOneImage//This can be change on the fly if you want to have multiple images on the front
  38. turnsecondimage = $MP_SpinSideTwoImage//You can change on the fly to have multiple images on the reverse side
  39.  
  40. [Idle]
  41. SpriteVars turningover turnback turnfirstimage turnsecondimage spinangle spinanglestep originalheight originalspincenterx originalspincentery spincenterx spincentery spinanglestep
  42. localvars temporaryx temporaryy spinheight
  43. //Figure out when to stop, and which direction to turn
  44. if(turningover)
  45. spinangle = (spinangle + spinanglestep*turningover + 720 ) rem 360
  46. if(turningover = 1 and spinangle > 179)
  47.     spinangle = 180
  48.     if(mousehorizontal > boundsleft and mousehorizontal < boundsright and mousevertical > boundstop and mousevertical < boundsbottom)
  49.     turningover = 0
  50.     else
  51.     turningover = -1
  52.     endif
  53. elseif(turningover = -1 and spinangle < 2)
  54.     spinangle = 0
  55.     if(mousehorizontal > boundsleft and mousehorizontal < boundsright and mousevertical > boundstop and mousevertical < boundsbottom)
  56.     turningover = 1
  57.     else
  58.     turningover = 0
  59.     endif
  60. endif
  61. setimageindexto(turnfirstimage)
  62. resetmatrix
  63. rotate(spinangle)
  64. spinheight = (SecondCornerY - FirstCornerY) * 0.1
  65. if(spinangle <= 90 or spinangle >= 270) 
  66. Stretch(FirstCornerX,SecondCornerY - spinheight,SecondCornerX, SecondCornerY + spinheight, SecondCornerX,SecondCornerY + originalheight - spinheight,FirstCornerX,SecondCornerY + originalheight + spinheight)
  67. else
  68.     setimageindexto(turnsecondimage)
  69. Stretch(SecondCornerX, SecondCornerY + spinheight,FirstCornerX,SecondCornerY - spinheight,FirstCornerX,SecondCornerY + originalheight + spinheight, SecondCornerX,SecondCornerY + originalheight - spinheight)
  70. endif
  71. executeevent(200082)
  72. MoveBy(originalspincenterx- spincenterx,originalspincentery - spincentery)
  73. else
  74.     if(turnback)
  75.         turningover = -1
  76.         turnback = false
  77.     endif
  78. endif
  79.  
  80. [200082 MP_CalculateSpinCenter]
  81. spritevars spincenterx spincentery
  82. //get the center of the sprite
  83. spincenterx = (boundsleft + boundsright)/2
  84. spincentery =  (boundstop + boundsbottom)/2
  85.